#define OUT 
#define IN


// short
// Network Package Type -- NPT
// RNPT -- Responsed Network Package Type.
#define NPT_REGISTRY			101
#define RNPT_REGISTRY			102

#define NPT_LOGIN				111
#define RNPT_LOGIN				112

#define NPT_MESSAGE				151
#define RNPT_MESSAGE			152
#define NPT_MESSAGE_ALL			161
#define RNPT_MESSAGE_ALL		162

#define NPT_TERMINAL			181
#define RNPT_TERMINAL			182

#define NPT_LOGOUT				201
#define RNPT_LOGOUT				202

#define NPT_TERM_SERVER			211


// reg: type|name|pwd|....
// login: type|name|pwd
// info: type|name|pwd|...
// msg: type|toid|fromid|msg
struct CMPMessageHeader
{
	unsigned char _type;	// package type. NPT_MESSAGE
	long _toid;				//
	long _fromid;			// 10000-100,0000,0000
	short _length;			// data length.

};
struct CMPMessageBody
{
//	short _length;
	char *data;
};

struct CMPRegisterHeader
{
	unsigned char _type;
	short _length;
};
struct CMPRegisterBody
{
//	short _length;
	short namelen;
	char *name;
	short pwdlen;
	char *pwd;
};
struct CMPLoginHeader
{
	unsigned char _type;
	short _length;
};
struct CMPLoginBody
{
//	short _length;
	short namelen;
	char *name;
	short pwdlen;
	char *pwd;
};

class CMyProtocol
{
public:
	CMyProtocol(void);
	~CMyProtocol(void);

public:
	void Register_read(IN char *streambuf, OUT char *name, OUT char *pwd);
	void Register_write(OUT char *streambuf, IN char *name, IN char *pwd);

	void Message_read();
	void Message_write();

	void Login_read(IN char *streambuf, OUT char *name, OUT char *pwd);
	void Login_write(OUT char *streambuf, OUT int &len, IN char *name, IN char *pwd);
};

